package com.franzliszt.OrderOnline.Activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.franzliszt.OrderOnline.sunzhengyi.custom.PayPwdEditText;
import com.franzliszt.OrderOnline.util.KillProcess;
import com.franzliszt.OrderOnline.util.SP;
import com.franzliszt.OrderOnline.util.ToastFormat;
import com.franzliszt.hospitalnumberingsystem.R;

public class PaymentActivity extends AppCompatActivity {
    private KillProcess killProcess;
    private PayPwdEditText payPassWord;
    private ToastFormat toastFormat;
    private TextView other,tip;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= 21) {
            View decorView = getWindow().getDecorView();
            decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE );
            getWindow().setStatusBarColor( Color.TRANSPARENT );
        }
        setContentView(R.layout.activity_payment);
        InitView();
        payPassWord.setOnTextFinishListener(new PayPwdEditText.OnTextFinishListener() {
            @Override
            public void onFinish(String str) {
                String Pay = "000000";
                if (str.equals( Pay ))
                {
                    toastFormat.setText("支付成功");
                    toastFormat.show();
                    startActivity(new Intent(PaymentActivity.this,PaySuccessActivity.class));
                }else {
                    toastFormat.setText("密码错误");
                    toastFormat.show();
                    payPassWord.clearText();
                }
            }
        });
    }
    private void InitView(){
        other = findViewById(R.id.exchangeFunc);
        other.setVisibility(View.GONE);
        tip = findViewById(R.id.ErrorTips);
        toastFormat = new ToastFormat(PaymentActivity.this);
        toastFormat.InitToast(R.layout.passworderror,R.id.ErrorTips, Gravity.CENTER);
        killProcess = KillProcess.getInstance();
        killProcess.addActivity(PaymentActivity.this);
        payPassWord = findViewById(R.id.payPassword);
        payPassWord.initStyle( R.drawable.bg_paypassword_style,6,3f,R.color.colorWhite,R.color.colorBlack,50);
    }
    public void Exit(View view){
        startActivity(new Intent(PaymentActivity.this,GoodsListActivity.class));
    }
}
